package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigDto;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigIdDto;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigQuery;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigStatusDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.pyq.PyqAutoConfigService;
import com.uzai.console.service.sysmaterial.SysMaterialService;
import com.uzai.console.vo.pyq.pyqautoconfig.PyqAutoConfigVo;
import com.uzai.console.vo.sysmaterial.UploadFileVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 朋友圈自动发圈配置
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "自动发圈配置",tags = "个人微信|朋友圈|自动发圈配置")
@ApiSort(31)
@RestController
public class PyqAutoConfigController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqAutoConfigController.class);

    @Autowired
    private PyqAutoConfigService pyqAutoConfigService;
    @Autowired
    private SysMaterialService sysMaterialService;

    @ApiOperation(value = "分页查询自动发圈配置列表", notes = "分页查询自动发圈配置列表", response = PyqAutoConfigVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqAutoConfig/findPyqAutoConfigList")
    public Object findPyqAutoConfigList(@RequestBody PyqAutoConfigQuery pyqAutoConfigQuery){
        return pyqAutoConfigService.findPyqAutoConfigList(pyqAutoConfigQuery);
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加自动发圈配置", notes = "添加自动发圈配置")
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqAutoConfig/addPyqAutoConfig")
    public Object addPyqAutoConfig(@RequestBody PyqAutoConfigDto pyqAutoConfigDto){
        pyqAutoConfigService.addPyqAutoConfig(pyqAutoConfigDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑自动发圈配置", notes = "编辑自动发圈配置" )
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqAutoConfig/updatePyqAutoConfig")
    public Object updatePyqAutoConfig(@RequestBody PyqAutoConfigDto pyqAutoConfigDto){
        pyqAutoConfigService.updatePyqAutoConfig(pyqAutoConfigDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除", notes = "删除")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqAutoConfig/deletePyqAutoConfig")
    public Object deletePyqAutoConfig(@RequestBody PyqAutoConfigIdDto pyqAutoConfigIdDto){
        pyqAutoConfigService.deletePyqAutoConfig(pyqAutoConfigIdDto);
        return true;
    }

    @ApiOperation(value = "查询自动发圈配置详情", notes = "查询自动发圈配置详情", response = PyqAutoConfigVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqAutoConfig/findPyqAutoConfig")
    public Object findPyqAutoConfig(@RequestBody PyqAutoConfigIdDto pyqAutoConfigIdDto){
        return pyqAutoConfigService.findPyqAutoConfig(pyqAutoConfigIdDto);
    }

    @ApiOperation(value = "上传本地图片", notes = "上传本地图片", response = UploadFileVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/pyqAutoConfig/uploadImage")
    public Object uploadImage(MultipartFile file){
        Long merId = getLoginInfo().getMerId();
        return sysMaterialService.uploadFile(file, merId);
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "开启关闭自动发圈配置", notes = "开启关闭自动发圈配置", response = Boolean.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/pyqAutoConfig/updateStatus")
    public Object updateStatus(@RequestBody PyqAutoConfigStatusDto pyqAutoConfigStatusDto){
        pyqAutoConfigService.updateStatus(pyqAutoConfigStatusDto);
        return true;
    }

}
